﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DLM.Infrastructure.Domain;

namespace DLM.Domain.Model
{
    public class Order : IValidatableObject, IAggregateRoot
    {
        public int OrderID { get; set; }

        [Required(ErrorMessage = "订单编号不允许为空")]
        public string OrderNo { get; set; }

        public string TradeNo { get; set; }

        public decimal Price { get; set; }

        public string Subject { get; set; }

        public string Body { get; set; }

        public string BuyerEmail { get; set; }

        public string TradeStatus { get; set; }

        public bool IsConfirmed { get; set; }

        public DateTime OrderDate { get; set; }

        public DateTime UpdateDate { get; set; }

        public int UserID { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrEmpty(OrderNo))
            {
                yield return new ValidationResult("订单号不允许为空", new string[] { "OrderNo" });
            }
        }
    }
}
